<include file="__THEME__/header" />
<link href="../Public/css/photo.css" rel="stylesheet" type="text/css" />
<!-- 头部 end -->

<div class="content"><!-- 内容 begin  -->

	<include file="__THEME__/apps" />

	<div class="main"> <!-- 右侧内容 begin  -->

		<div class="page_title"> <!-- page_title begin -->
			<h2><img src="{$APPINFO['APP_ICON']}" />{$APPINFO['APP_CNNAME']}</h2>
		<div class="c"></div>
</div><!-- page_title end -->

		<div class="tab-menu"><!-- 切换标签 begin  -->
		<ul>
			<li><a href="__URL__/index<if condition=" $_GET['albumId'] gt 0 ">/albumId/{.albumId}</if>"><span>普通上传</span></a></li>
			<li><a href="__URL__/flash" class="on"><span>批量上传</span></a></li>
			<if condition="$setting['open_camera'] eq 1"><li><a href="__URL__/camera"><span>在线拍照</span></a></li></if>
            <li><a href="__APP__/Index/photos"><span>返回我的{$APPINFO['APP_CNNAME']}</span></a></li>
		</ul>
		</div><!-- 切换标签 end  -->
		
		<div class="photoBox">
			<div class="upload">
			<ul style="width:500px;">
            <form method="post" action="__APP__/Upload/muti_edit_photos" enctype="application/x-www-form-urlencoded" name="muti_edit_photos" id="muti_edit_photos">
        	<li><div class="c1">选择{$APPINFO['APP_CNNAME']}专辑：</div>
				<div class="c2">
                {:W('AlbumList',array( 'uid'=>$mid , 'form_name'=>'albumId' , 'selected'=>intval($_GET['albumId']),'table_pre'=>'photo_') )}
                <a href="#" onclick="create_album({$mid})">[创建专辑]</a>
				</div>
        	</li>     
            <li>
				<div class="c1"><input type="hidden" name="upnum" id="up_num" value="0" />
                	<span id="flash_upload_select_picture"></span>
				</div>
              <div class="c2">
                <div class="rank" id="flash_upload_progress" style="border:solid 1px #CCC;height:220px; width:375px; overflow: scroll;"></div>
                </div>
        	</li>
            <li>
              	<div class="c1">
					&nbsp;
                </div>
                <div class="c2">
               		<input type="button" class="btn_b" value="开始上传" id="btnUpload" onClick='start_upload()' disabled="disabled" />
                </div>
        	</li>
			<!--<li>
              <div class="c1">&nbsp;</div>
                <div class="c2"><input name="" type="checkbox" value="" /> 
                添加到专辑后面 </div>
        	</li> -->
        </form>
        </ul>
        <div class="clue">
			<p>·可以同时选择多张{$APPINFO['APP_CNNAME']}进行批量上传 (注:一次最多同时上传{$max_flash_upload_num}张{$APPINFO['APP_CNNAME']})    </p>
			<p>·单张图最大为2M，支持JPG、GIF、PNG格式，如果上传失败，请尝试小一点的图片。</p>
			<p>·切换到缩略图模式预览文件夹<br /> 可直观挑选{$APPINFO['APP_CNNAME']}： <img src="../Public/images/uploadEx.gif" width="136" height="27" /></p>
			<span class="clue_btm"></span>
		</div>
		<!-- 上传{$APPINFO['APP_CNNAME']}预览 -->
		<div id="uploaded_photos" style="clear:both;"></div>
    </div>
    </div>  </div><!-- 右侧内容 end  -->
  <div class="c"></div>
</div><!-- 内容 end -->
<include file="__THEME__/footer" />
<script src="../Public/js/album.js" type="text/javascript"></script>
<link href="../Public/js/swfupload/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Public/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="../Public/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="../Public/js/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="../Public/js/swfupload/handlers.js"></script>
<script>
	var swfu;
	window.onload = function() {
		var settings = {

			// Backend Settings
			upload_url: "__APP__/Upload/upload_single_pic",	// Relative to the SWF file (or you can use absolute paths)
			post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},

			// File Upload Settings
			file_size_limit : "2048",	// 3MB
			file_types : "*.jpg;*.gif;*.png;*.bmp",
			file_types_description : "All Files",
			file_upload_limit	:	"{$max_flash_upload_num}",	//最多上传30张
			file_queue_limit	:	"{$max_flash_upload_num}",	//最多选择30张

			// Event Handler Settings (all my handlers are in the Handler.js file)
			file_dialog_start_handler :		fileDialogStart,
			file_queued_handler :			fileQueued,
			file_queue_error_handler :		fileQueueError,
			file_dialog_complete_handler :	fileDialogComplete,
			upload_start_handler :			uploadStart,
			upload_progress_handler :		uploadProgress,
			upload_error_handler :			uploadError,
			upload_success_handler :		uploadSuccess,
			upload_complete_handler :		uploadComplete,
			queue_complete_handler :		queueComplete,

			// Button Settings
			button_image_url : "../Public/js/swfupload/add_photo.png",	// Relative to the SWF file
			button_placeholder_id : "flash_upload_select_picture",
			button_width:	74,
			button_height:	25,

			// Flash Settings
			flash_url : "../Public/js/swfupload/swfupload.swf",

			custom_settings : {
				progressTarget : "flash_upload_progress",
				cancelButtonId : "btnCancel1"
			},
			debug: false
		};

		swfu = new SWFUpload(settings);
	};

//开始上传
function start_upload(){
	albumId	=	$('#albumlist').val();
	if(albumId>0){
		swfu.addPostParam('albumId',albumId);
		swfu.startUpload();
		$('#btnUpload').attr('disabled',true).removeClass('btn5').val("上传中，请稍后...");
	}else{
		alert('{$APPINFO['APP_CNNAME']}专辑未选择，请添加新专辑或者刷新页面重试！');
	}
}

//单图上传回调函数,返回上传完成文件的信息
function ts_upload_success(serverData){
	var data	=	eval('('+serverData+')');
	if(data.status==true){
		return true;
	}else{
		alert(data.info);
		return true;
	}
}

//当文件队列有文件时
function enableUploadButton(file){
	$('#btnUpload').attr('disabled',false).addClass('btn5').val("开始上传");
}
//全部上传完成
function queueComplete(numFilesUploaded) {
	$("#up_num").val(numFilesUploaded);
	$("#muti_edit_photos").submit();
}
</script>